import { postAction } from "@/command/netTool";
import { useDetail } from "@/hooks";
import router from "@/router";
import * as vant from "vant";
const { showFailToast, showSuccessToast } = vant;

export const useRequest = () => {
  const [problemType] = useDetail(
    "/api/H5/util/getDictType?dictType=problem_type",
    [],
    {
      callBack: (data: any[]) => {
        return data.filter((e) => e.value != "-1");
      },
    }
  );
  const confirm = (params: any) => {
    // if (!params.name) {
    //   showFailToast("请输入姓名");
    //   return;
    // }
    // if (!params.phone) {
    //   showFailToast("请输入联系电话");
    //   return;
    // }
    // if (!params.type) {
    //   showFailToast("请选择问题类型");
    //   return;
    // }
    postAction("/api/H5/gov/perCenter/saveRichFeedback", { ...params }).then(
      () => {
        showSuccessToast("保存意见反馈成功！");
        setTimeout(() => {
          router.back();
        }, 2000);
      }
    );
  };

  return { confirm, problemType };
};
